import os,xlrd
from common.log import logger

class ReadData:
    def __init__(self):
        self.path=os.path.dirname(os.path.dirname(__file__))+r"\testData\data.xls"

    def read_excel(self,cname,mname):
        logger.info(f"要测试的类名{cname},要测试的方法名{mname}")
        read=xlrd.open_workbook(self.path)
        sheet=read.sheet_by_index(0)
        max_row=sheet.nrows
        max_col=sheet.ncols
        first_line=sheet.row_values(0)
        for i in range(1,max_row):
            row=sheet.row_values(i)
            dict1=dict(zip(first_line,row))
            if dict1["classname"]==cname and dict1["methodname"]==mname:
                logger.info(f'读取到的测试数据为{dict1["testdata"]}')
                return dict1["testdata"]

if __name__ == '__main__':
    rd=ReadData()
    print(rd.read_excel('SearchTest','test_normal_len'))